package cn.lopr.im.api.controller;

import cn.lopr.im.api.common.CallbackMessage;
import cn.lopr.im.api.service.ICosService;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shuangyang7
 * @date 2021/5/20 16:04
 */
@RestController
@RequestMapping("/cos")
public class CosController {

    @Autowired
    private ICosService cosService;

    @RequestMapping("/getTempSecret")
    @ResponseBody
    public CallbackMessage<?> getTempSecret() {
        JSONObject tempSecret = cosService.getTempSecret();

        if (tempSecret == null) {
            return CallbackMessage.createByError();
        }

        return CallbackMessage.createBySuccess("获取成功", tempSecret.toMap());
    }
}
